home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / networ1a / portbloc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-16  |  6.7 KB  |  212 lines

  1. VERSION 5.00
  2. Object = "{FFACF7F3-B868-11CE-84A8-08005A9B23BD}#1.7#0"; "DSSOCK32.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Port Blocker Example"
  6.    ClientHeight    =   1965
  7.    ClientLeft      =   1140
  8.    ClientTop       =   1515
  9.    ClientWidth     =   3510
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   1965
  15.    ScaleWidth      =   3510
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.CommandButton Command2 
  18.       Caption         =   "stop"
  19.       Enabled         =   0   'False
  20.       Height          =   195
  21.       Left            =   2520
  22.       TabIndex        =   7
  23.       Top             =   120
  24.       Width           =   735
  25.    End
  26.    Begin VB.CommandButton Command1 
  27.       Caption         =   "start"
  28.       Height          =   195
  29.       Left            =   1680
  30.       TabIndex        =   6
  31.       Top             =   120
  32.       Width           =   735
  33.    End
  34.    Begin VB.TextBox Text1 
  35.       Height          =   855
  36.       Left            =   0
  37.       MultiLine       =   -1  'True
  38.       ScrollBars      =   2  'Vertical
  39.       TabIndex        =   5
  40.       Top             =   1080
  41.       Width           =   3495
  42.    End
  43.    Begin VB.TextBox Text2 
  44.       Height          =   285
  45.       Left            =   1320
  46.       TabIndex        =   3
  47.       Text            =   "sorry kids, this port is blocked"
  48.       Top             =   480
  49.       Width           =   2175
  50.    End
  51.    Begin VB.TextBox Text3 
  52.       Height          =   285
  53.       Left            =   720
  54.       TabIndex        =   1
  55.       Text            =   "31337"
  56.       Top             =   0
  57.       Width           =   735
  58.    End
  59.    Begin dsSocketLib.dsSocket dsSocket2 
  60.       Height          =   420
  61.       Left            =   3120
  62.       TabIndex        =   9
  63.       Top             =   840
  64.       Width           =   420
  65.       _Version        =   65543
  66.       _ExtentX        =   741
  67.       _ExtentY        =   741
  68.       _StockProps     =   64
  69.       LocalPort       =   0
  70.       RemoteHost      =   ""
  71.       RemotePort      =   0
  72.       ServiceName     =   ""
  73.       RemoteDotAddr   =   ""
  74.       Linger          =   -1  'True
  75.       Timeout         =   10
  76.       LineMode        =   0   'False
  77.       EOLChar         =   10
  78.       BindConnect     =   0   'False
  79.       SocketType      =   0
  80.    End
  81.    Begin dsSocketLib.dsSocket dsSocket1 
  82.       Height          =   420
  83.       Left            =   2640
  84.       TabIndex        =   8
  85.       Top             =   840
  86.       Width           =   420
  87.       _Version        =   65543
  88.       _ExtentX        =   741
  89.       _ExtentY        =   741
  90.       _StockProps     =   64
  91.       LocalPort       =   0
  92.       RemoteHost      =   ""
  93.       RemotePort      =   0
  94.       ServiceName     =   ""
  95.       RemoteDotAddr   =   ""
  96.       Linger          =   -1  'True
  97.       Timeout         =   10
  98.       LineMode        =   0   'False
  99.       EOLChar         =   10
  100.       BindConnect     =   0   'False
  101.       SocketType      =   0
  102.    End
  103.    Begin VB.Label Label3 
  104.       BackStyle       =   0  'Transparent
  105.       Caption         =   "Status:"
  106.       BeginProperty Font 
  107.          Name            =   "MS Sans Serif"
  108.          Size            =   9.75
  109.          Charset         =   0
  110.          Weight          =   700
  111.          Underline       =   0   'False
  112.          Italic          =   0   'False
  113.          Strikethrough   =   0   'False
  114.       EndProperty
  115.       Height          =   255
  116.       Left            =   120
  117.       TabIndex        =   4
  118.       Top             =   840
  119.       Width           =   735
  120.    End
  121.    Begin VB.Label Label2 
  122.       BackStyle       =   0  'Transparent
  123.       Caption         =   "Comment:"
  124.       BeginProperty Font 
  125.          Name            =   "MS Sans Serif"
  126.          Size            =   9.75
  127.          Charset         =   0
  128.          Weight          =   700
  129.          Underline       =   0   'False
  130.          Italic          =   0   'False
  131.          Strikethrough   =   0   'False
  132.       EndProperty
  133.       Height          =   255
  134.       Left            =   120
  135.       TabIndex        =   2
  136.       Top             =   480
  137.       Width           =   1095
  138.    End
  139.    Begin VB.Label Label1 
  140.       BackStyle       =   0  'Transparent
  141.       Caption         =   "Port:"
  142.       BeginProperty Font 
  143.          Name            =   "MS Sans Serif"
  144.          Size            =   9.75
  145.          Charset         =   0
  146.          Weight          =   700
  147.          Underline       =   0   'False
  148.          Italic          =   0   'False
  149.          Strikethrough   =   0   'False
  150.       EndProperty
  151.       Height          =   255
  152.       Left            =   120
  153.       TabIndex        =   0
  154.       Top             =   0
  155.       Width           =   495
  156.    End
  157. Attribute VB_Name = "Form1"
  158. Attribute VB_GlobalNameSpace = False
  159. Attribute VB_Creatable = False
  160. Attribute VB_PredeclaredId = True
  161. Attribute VB_Exposed = False
  162. Private Sub Command1_Click()
  163. On Error Resume Next
  164. '  --- start listening for connections ---  '
  165. Command2.Enabled = True  ' enabled the stop button
  166. Command1.Enabled = False ' disable the start button
  167. dsSocket1.LocalPort = Text3 ' set the port
  168. dsSocket1.Listen ' listen for connection
  169. End Sub
  170. Private Sub Command2_Click()
  171. On Error Resume Next
  172. '  --- stop listening for connections ---  '
  173. Command1.Enabled = True ' enabled the start button
  174. Command2.Enabled = False ' disable the stop button
  175. dsSocket1.Close ' close socket
  176. dsSocket2.Close ' close socket
  177. End Sub
  178. Private Sub dsSocket1_Accept(SocketID As Integer)
  179. On Error Resume Next
  180. dsSocket2.Socket = SocketID ' set the socket
  181. dsSocket1.Close ' close the socket that was
  182.                 ' listening
  183. If Len(Text2) > 0 Then dsSocket2.Send = Text2
  184.   ' if there was a message to send to the person
  185.   ' trying to connect, send it.  if not, dont send
  186. dsSocket2.Close ' close other socket
  187. Command2.Enabled = False ' disable the stop button
  188. Command1.Enabled = True ' enabled the start button
  189. End Sub
  190. Private Sub dssocket2_Connect()
  191. ' this control is only used to send the comment
  192. ' to the person trying to connect.  other then that
  193. ' it isn't used.  i bet it feels left out  ;[
  194. ' hehe....
  195. End Sub
  196. Private Sub Form_Load()
  197. On Error Resume Next
  198. dsSocket1.Close
  199. dsSocket2.Close
  200.  ' i just do this to make sure the socket is closed
  201.  ' its not really needed, but what the hell... hehe
  202. End Sub
  203. Private Sub Form_Terminate()
  204. End Sub
  205. Private Sub Form_Unload(Cancel As Integer)
  206. On Error Resume Next
  207. dsSocket1.Close ' close sockets so you wont error
  208.                 ' the next time you run the program
  209. dsSocket2.Close ' close sockets
  210.                 ' the next time you run the program
  211. End Sub
  212.